package com.ljh.SimpleTradingSystem.mybatis.mapper;

import com.ljh.SimpleTradingSystem.mybatis.entity.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CommentMapper {
    @Select("select * from comment where goodsId = #{goodsId}")
    List<Comment> selectByGoodsId(int goodsId);

    @Insert("insert into comment(goodsId, userName, text, commentTime)" +
            "values (#{goodsId}, #{userName}, #{text}, #{commentTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Comment comment);
}
